﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Cocon90.Lib.Dal.Utility
{
    /// <summary>
    /// SQLServer数据库操作实例
    /// </summary>
    public class SQLDataHelper : DataHelper
    {
        #region DataHelper 成员
        public override DbCommand createCommond(string tsql, CommandType commandType, params System.Data.Common.DbParameter[] paramKeyAndValue)
        {
            SqlConnection conn = new SqlConnection(GetConnectionString);
            conn.Open();
            SqlCommand cmd = new SqlCommand(tsql, conn);
            cmd.CommandText = tsql;
            cmd.CommandType = commandType;
            foreach (var para in paramKeyAndValue)
            {
                cmd.Parameters.Add(para);
            }
            return cmd;
        }
        public override DbDataAdapter createDataAdapter(System.Data.Common.DbCommand selectCmd)
        {
            SqlDataAdapter dap = new SqlDataAdapter((SqlCommand)selectCmd);
            return dap;
        }
        public override DbParameter createParameter(string key, object value)
        {
            SqlParameter para = new SqlParameter(key, value);
            return para;
        }
        #endregion
    }
}
